package com.sservice.banfu.service.impl;

import com.sservice.banfu.mapper.AuctionRegisterMapper;
import com.sservice.banfu.e.AuctionRegister;
import com.sservice.banfu.service.AuctionRegisterService;
import com.sservice.generator.service.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * Created by byte_su@163.com on 2018/01/25.
 */
@Service
public class AuctionRegisterServiceImpl extends AbstractService<AuctionRegister> implements AuctionRegisterService {

    @Autowired
    private AuctionRegisterMapper auctionRegisterMapper;

    @Override
    public List<AuctionRegister> queryByPage(AuctionRegister user) {
        Example example = new Example(AuctionRegister.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("ownerId", user.getOwnerId());
        criteria.andEqualTo("status", user.getStatus());
        criteria.andEqualTo("id", user.getId());
        return auctionRegisterMapper.selectByExample(example);
    }

    @Override
    public int queryCount(AuctionRegister user) {
        Example example = new Example(AuctionRegister.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("ownerId", user.getOwnerId());
        criteria.andEqualTo("status", user.getStatus());
        return auctionRegisterMapper.selectCountByExample(example);
    }

    @Override
    public int count(AuctionRegister auctionRegister) {
        return auctionRegisterMapper.count(auctionRegister);
    }

    @Override
    public List<AuctionRegister> query(AuctionRegister auctionRegister) {
        return auctionRegisterMapper.query(auctionRegister);
    }

    @Override
    public int updateByPrimaryKeySelective(AuctionRegister auctionRegister) {
        return auctionRegisterMapper.updateByPrimaryKeySelective(auctionRegister);
    }

    @Override
    public AuctionRegister selectById(Integer id) {
        AuctionRegister auctionRegister = new AuctionRegister();
        auctionRegister.setId(id);
        return auctionRegisterMapper.selectById(auctionRegister);
    }
}
